import { Component, NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { NavController, NavParams, IonicApp } from 'ionic-angular';
import { Storage } from '@ionic/storage';
import { FormBuilder, FormGroup, FormControl } from "@angular/forms";
//import { NgModule } from '@angular/core';
import { Http, Headers, RequestOptions } from '@angular/http';
import { registerPage } from '../register/register';
//import fileLogger from '@cordova-plugin-file';

//declare var angular: IonicApp;
//declare var angular: any;

//import { ngCordova } from 'ng-cordova';
//import { filelogger } from 'ionic-filelogger';

/*
  Generated class for the login page.

  See http://ionicframework.com/docs/v2/components/#navigation for more info on
  Ionic pages and navigation.
*/
@Component({
    selector: 'page-login',
    templateUrl: 'login.html'
})
export class loginPage {
    loginForm: FormGroup;
    results: any;
    username: any;
    constructor(public navCtrl: NavController, public navParams: NavParams, private formBuilder: FormBuilder, public http: Http) {
        this.loginForm = formBuilder.group({
            username: new FormControl(),
            phoneNo: new FormControl()
        });
        
    }
    IDvalidate(_event) {

        _event.preventDefault();

        ////let header = new Headers();
        ////header.append('Content-Type','application/json');
        //let id: string = this.username.value.toString();
        //let body = JSON.stringify({
        //    userid: id
        //});
        //var headers = new Headers();
        //headers.append("Accept", 'application/json');
        //headers.append('Content-Type', 'application/json;charset=UTF-8');
        ////let headers = new Headers({

        ////    'Content-Type': 'application/json'

        ////});

        //let options = new RequestOptions({
        //    headers: headers
        //});
        //return new Promise((resolve, reject) => {

        //    this.http.post("http://192.168.1.203:8800/Neeq/CheckUserId", body, options)

        //        .subscribe(data => {
        //            this.results = data.json();
        //            console.log(this.results['code']);
        //            if (this.results['code'] == '0') {
        //                console.log("成功");
        //            }
        //            else {
        //                console.log(this.results['msg']);
        //            }
        //        }
        //        , err => console.log(reject(err)))
        //})
    }
    login(_event)
    {
        _event.preventDefault();
       // filelogger.setStorageFilename('myLog.txt');
    }
    Forget(_event)
    {
        _event.preventDefault();

    }
    register(_event) {//注册
        _event.preventDefault();
        this.navCtrl.push(registerPage);
    }
    ionViewDidLoad() {
        console.log('ionViewDidLoad loginPage');
    }

}
